﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace DicomLibrary
{
    public static class DExtensions
    {
        public static DDataElement GetDataElement(this List<DDataElement> list, short GroupNumber, short ElementNumber)
        {
            return list.Single(pd => pd.Tag.GroupNumber == GroupNumber && pd.Tag.ElementNumber == ElementNumber);
        }

        public static Boolean IsExplicit(this DTransferSyntax ts)
        {
            FieldInfo field = ts.GetType().GetField(ts.ToString());
            IsExplicitAttribute[] iea = (IsExplicitAttribute[])field.GetCustomAttributes(typeof(IsExplicitAttribute), false);
            return (iea.Length > 0) ? iea[0].IsExplicit : false;
        }
    }
}
